<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .box{
            width: 550px;
            margin: 50px auto;
            border: 1px solid #000;
            text-align: center;
        }
        .box button{
            width: 80px;
            height: 30px;
        }
        .top{
            border-bottom: 1px solid #000;
        }
        .bottom div{
            height: 500px;
            width: 100%;
            background: red;
            display: none;
        }

    </style>
</head>
<body>
    <div class="box">
        <div class="top">
            <button>1号</button>
            <button>2号</button>
            <button>3号</button>
            <button>4号</button>
            <button>5号</button>
            <button>6号</button>
        </div>
        <div class="bottom">
            <div style="display:block">1<h1>这里有个h1标题</h1></div>
            <div>2<h2>这里有个h2标题</h2></div>
            <div>3<h3>这里有个h3标题</h3></div>
            <div>4<h4>这里有个h4标题</h4></div>
            <div>5<h5>这里有个h5标题</h5></div>
            <div>6<h6>这里有个h6标题</h6></div> 
        </div>
    </div>
    <script>
        var btns = document.getElementsByTagName("button");
        var divs = document.getElementsByClassName("bottom")[0].getElementsByTagName("div");
        for(var i=0;i<btns.length;i++){
            btns[i].index = i;
            btns[i].onclick = function(){
                for(var i=0;i<btns.length;i++){
                    //排他
                    btns[i].style.background = "";
                    
                    //排他
                    divs[i].style.display= "none";
                   
                }  
                this.style.background = "pink";
                divs[this.index].style.display = "block"
            }
        }
    </script>
</body>
</html>